package org.xiaojinlong.exam;

import java.util.Scanner;

/**
 * @author Jin Long
 * 2015/9/25
 */
public class Didi2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String line = scanner.nextLine();
            String[] strNums = line.split(" ");

            int[] nums = new int[strNums.length];
            for (int i = 0; i < nums.length; i++) {
                nums[i] = Integer.parseInt(strNums[i]);
            }

            int maxLen = 0, index = 0;
            for (int i = 0; i < nums.length; i++) {
                int sum = nums[i];
                if (maxLen == 0 && sum == 0) {
                    index = i;
                    maxLen = 1;
                }

                for (int j = i + 1; j < nums.length; j++) {
                    sum += nums[j];
                    if (sum == 0 && (j - i + 1) > maxLen) {
                        index = i;
                        maxLen = j - i + 1;
                    }
                }
            }

            for (int i = index, len = index + maxLen; i < len; i++)
                System.out.print(nums[i] + " ");

        }
    }
}
